Fix frameclock going backwards
authorAlexander Larsson <alexl@redhat.com>
Mon, 1 Jun 2020 08:53:24 +0000 (10:53 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 1 Jun 2020 08:53:24 +0000 (10:53 +0200)
commita36e2bc764ba493a07c982995e1f76eac53a9383
tree4ec9b341f158ce8c8996f0d90765fd062c67a871
parented02bea20da1ab73e97c65dbcb6b3bd8f0d40d14
Fix frameclock going backwards

When we run the frameclock RUN_FLUSH_IDLE idle before the paint,
then gdk_frame_clock_flush_idle() sets
```
  priv->phase = GDK_FRAME_CLOCK_PHASE_BEFORE_PAINT
```
at the end if there is a paint comming.

But, before doing the paint cycle it may handle other X events, and
during that time the phase is set to BEFORE_PAINT. This means that the
current check on whether we're inside a paint is wrong:

```
  if (priv->phase != GDK_FRAME_CLOCK_PHASE_NONE &&
     priv->phase != GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS)
    return priv->smoothed_frame_time_base;
```

This caused us to sometimes use this smoothed_frame_time_base even
though we previously reported a later value during PHASE_NONE, thus
being non-monotonic.

We can't just additionally check for the BEGIN_PAINT phase though,
becasue if we are in the paint loop actually doing that phase we
should use the time base. Instead we check for `!(BEFORE_PAINT &&
in_paint_idle)`.
gdk/gdkframeclockidle.c